﻿@using Volo.Abp.UI.Navigation
@model ApplicationMenu
@foreach (var menuItem in Model.Items)
{
    var elementId = string.IsNullOrEmpty(menuItem.ElementId) ? string.Empty : $"id=\"{menuItem.ElementId}\"";
    var cssClass = string.IsNullOrEmpty(menuItem.CssClass) ? string.Empty : menuItem.CssClass;
    var disabled = menuItem.IsDisabled ? "disabled" : string.Empty;

    if (menuItem.IsLeaf)
    {
        if (menuItem.Url == null)
        {
            continue;
        }

        <li class="nav-item @cssClass @disabled" @elementId>
            <a class="nav-link" href="@(menuItem.Url ?? "#")">
                @if (menuItem.Icon != null)
                {
                    if (menuItem.Icon.StartsWith("fa"))
                    {
                        <i class="@menuItem.Icon"></i>
                    }
                }
                @menuItem.DisplayName
            </a> @*<span class="sr-only">(current)</span>*@
        </li>
    }
    else
    {
        <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="Menu_@(menuItem.Name)" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">@menuItem.DisplayName</a>
            <div class="dropdown-menu" aria-labelledby="Menu_@(menuItem.Name)">
                @foreach (var childMenuItem in menuItem.Items)
                {
                    <a class="dropdown-item @cssClass @disabled" href="@(childMenuItem.Url ?? "#")" @Html.Raw(elementId)>
                        @childMenuItem.DisplayName
                    </a>
                }
            </div>
        </li>
    }
}
